<?php

class Application_Model_Tools {

	public function genRandomString() {
		$length = 5;
		$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
		$string = '';

		for ($p = 0; $p < $length; $p++) {
			$string .= $characters[mt_rand(0, strlen($characters))];
		}

		return $string;
	}
	
	public function genUniqeFileName() {		
		return time().$this->genRandomString().".jpg";
	}

        public function orderArrayByField($arrayS, $fieldName, $order = 'ASC') {
            $tempArr = array();
            foreach ($arrayS as $key => $value) {
                $tempArr["$key"] = $value[$fieldName];
            }
            asort($tempArr);
            $final = array();
            foreach ($tempArr as $key => $value) {
                $final[] = $arrayS[$key];
            }
            return $final;
        }

}